home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
comm
/
brc_asp1.zip
/
ZIPDATE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-01-30
|
5KB
|
98 lines
program ZipDate; {change the date/time of ZIP files to the
latest date/time of any file within}
uses
dos, ZipDir; {I got the ZipDir unit from the Atkinson Home Computer BBS}
{I hope I am not violating anyone by including it here}
{ This program was written by Bruce Clawson, Wauwatosa, WI USA.
The unit 'ZIPDIR.PAS' was picked up from the Atkinson Home Computer BBS
some time ago. As I can't find any docs for it I sincerely hope that
I am not violating anyone's rights by including it here.
My program (ZIPDATE.PAS) is released to the public domain. You are
free to use/abuse/modify/distribute it as you wish but please leave
this comment area intact. Direct comments to me on EXEC-PC. }
{ compiled with Borland's Turbo Pascal 6.0 }
procedure DateFixer (NameParam : pathstr);
var
ZipFile : text; {the ZIP file itself}
Drect : SearchRec; {defined in DOS unit}
ZipDirect : DirStr; {defined in DOS unit}
ZipName : NameStr; {defined in DOS unit}
ZipExt : ExtStr; {defined in DOS unit}
FullPathName : string; {used to construct a fully qualified name}
ZipDirItem : string; {ZIP directory item from 'ZIPDIR' unit}
ZfDaTi : longint; {file date/time in system format}
ZfDateTime : DateTime; {file date/time structure (DOS unit)}
ZipDateTime : string; {used to find newest member file}
TmpDateTime : string; {used to find newest member file}
ZipDirStatus : integer; {status returned by 'ZIPDIR' unit}
ErrCode : integer; {'val' Error Code}
Counter : byte; {what it says}
begin
for Counter := 1 to length (NameParam) do {convert to upper case}
NameParam [Counter] := upcase (NameParam [Counter]);
fsplit (NameParam, ZipDirect, ZipName, ZipExt); {split up}
if ZipExt <> '.ZIP' {we want ZIP files only}
then exit;
FindFirst (NameParam, Archive, Drect); {find the first file matching the mask}
while DosError = 0 do
begin
FullPathName := ZipDirect + Drect.Name; {fully qualified name}
assign (ZipFile,FullPathName); {assign the ZIP file}
reset (ZipFile); {open for input}
getftime (ZipFile,ZfDaTi); {get its date/time}
unpacktime (ZfDaTi, ZfDateTime); {convert to usable format}
ZipDateTime := '00000000000000'; {clear out}
ZipDirSetup (FullPathName,ZipDirStatus); {do ZIP directory setup}
while ZipDirStatus = 0 do {until 'eof'}
begin
ZipDirFetch (ZipDirItem,ZipDirStatus); {get ZIP member file info}
TmpDateTime := copy (ZipDirItem,35,4) {year}
+ copy (ZipDirItem,29,2) {month}
+ copy (ZipDirItem,32,2) {day}
+ copy (ZipDirItem,40,2) {hour}
+ copy (ZipDirItem,43,2) {minute}
+ copy (ZipDirItem,46,2); {second}
if TmpDateTime > ZipDateTime {which is later?}
then ZipDateTime := TmpDateTime;
end;
with ZfDateTime do {plug back into DOS.DateTime format}
begin
val (copy (ZipDateTime, 1,4),Year, ErrCode);
val (copy (ZipDateTime, 5,2),Month,ErrCode);
val (copy (ZipDateTime, 7,2),Day, ErrCode);
val (copy (ZipDateTime, 9,2),Hour, ErrCode);
val (copy (ZipDateTime,11,2),Min, ErrCode);
val (copy (ZipDateTime,13,2),Sec, ErrCode);
end;
packtime (ZfDateTime,ZfDaTi); {convert to system format}
setftime (ZipFile,ZfDaTi); {update disk directory values}
close (ZipFile); {close the file}
writeln;
write (FullPathName, ' '); {show it on the screen}
write (copy (ZipDateTime,5,2), '-');
write (copy (ZipDateTime,7,2), '-');
writeln (copy (ZipDateTime,3,2));
FindNext (Drect); {look for another file}
end; {while DosError = 0}
end; {DateFixer}
{*********************************}
{-----MAINLINE PROGRAM CODING-----}
{*********************************}
var
Count : word;
CurrDir : string;
begin {MainProgram}
if ParamCount = 0 {if no command line parameters}
then begin
getdir (0, CurrDir); {use current dirve:\directory}
if CurrDir [length (CurrDir)] <> '\'
then CurrDir := CurrDir + '\'; {append a '\' if needed}
DateFixer (CurrDir + '*.ZIP'); {look for ZIP files}
end
else for Count := 1 to ParamCount do
DateFixer (ParamStr (Count)); {use command line parameters}
end. {MainProgram}